home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / v cisle / tclock / tclocklight-040702-3.exe / source / property / pagetooltip.c < prev    next >
C/C++ Source or Header  |  2004-09-07  |  4KB  |  165 lines

  1. /*-------------------------------------------------------------
  2.   pagetooltip.c : "Cuckoo" page of properties
  3.   (C) Kazuto Sato 1997-2003
  4.   For the license, please read readme.txt.
  5.   
  6.   Written by Kazubon, Nanashi-san
  7. ---------------------------------------------------------------*/
  8.  
  9. #include "tcprop.h"
  10.  
  11. /* Globals */
  12.  
  13. BOOL CALLBACK PageTooltipProc(HWND hDlg, UINT message,
  14.     WPARAM wParam, LPARAM lParam);
  15.  
  16. /* Statics */
  17.  
  18. static void SendPSChanged(HWND hDlg);
  19. static void OnInit(HWND hDlg);
  20. static void OnApply(HWND hDlg);
  21. static void OnUseTip1(HWND hDlg);
  22.  
  23. static BOOL  m_bInit = FALSE;
  24. static BOOL  m_bChanged = FALSE;
  25.  
  26. static char *m_section = "Tooltip";
  27.  
  28. /*------------------------------------------------
  29.   Dialog procedure
  30. --------------------------------------------------*/
  31. BOOL CALLBACK PageTooltipProc(HWND hDlg, UINT message,
  32.     WPARAM wParam, LPARAM lParam)
  33. {
  34.     switch(message)
  35.     {
  36.         case WM_INITDIALOG:
  37.             OnInit(hDlg);
  38.             return TRUE;
  39.         case WM_COMMAND:
  40.         {
  41.             WORD id, code;
  42.             id = LOWORD(wParam); code = HIWORD(wParam);
  43.             switch(id)
  44.             {
  45.                 case IDC_USETOOLTIP1:
  46.                     OnUseTip1(hDlg);
  47.                     SendPSChanged(hDlg);
  48.                     break;
  49.                 case IDC_TOOLTIP:
  50.                 case IDC_TOOLTIPTIME:
  51.                     if(code == EN_CHANGE) SendPSChanged(hDlg);
  52.                     break;
  53.                 case IDC_TOOLTIPSTYLE1:
  54.                 case IDC_TOOLTIPSTYLE2:
  55.                     SendPSChanged(hDlg);
  56.                     break;
  57.             }
  58.             return TRUE;
  59.         }
  60.         case WM_NOTIFY:
  61.             switch(((NMHDR *)lParam)->code)
  62.             {
  63.                 case PSN_APPLY: OnApply(hDlg); break;
  64.                 case PSN_HELP: MyHelp(GetParent(hDlg), "Tooltip"); break;
  65.             }
  66.             return TRUE;
  67.     }
  68.     return FALSE;
  69. }
  70.  
  71. /*------------------------------------------------
  72.   notify parent window to enable "Apply" button
  73. --------------------------------------------------*/
  74. void SendPSChanged(HWND hDlg)
  75. {
  76.     if(m_bInit)
  77.     {
  78.         g_bApplyTip = TRUE;
  79.         m_bChanged = TRUE;
  80.         SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)(hDlg), 0);
  81.     }
  82. }
  83.  
  84. /*------------------------------------------------
  85.   initialize
  86. --------------------------------------------------*/
  87. void OnInit(HWND hDlg)
  88. {
  89.     char s[BUFSIZE_TOOLTIP];
  90.     BOOL b;
  91.     int n;
  92.     
  93.     m_bInit = FALSE;
  94.     
  95.     // common/tclang.c
  96.     SetDialogLanguage(hDlg, "Tooltip", g_hfontDialog);
  97.     
  98.     UpDown_SetBuddy(hDlg, IDC_TOOLTIPTIMESPIN, IDC_TOOLTIPTIME);
  99.     
  100.     b = GetMyRegLong(m_section, "Tip1Use", TRUE);
  101.     CheckDlgButton(hDlg, IDC_USETOOLTIP1, b);
  102.     
  103.     GetMyRegStr(m_section, "Tooltip", s, BUFSIZE_TOOLTIP,
  104.         "\"TClock\" LDATE");
  105.     SetDlgItemText(hDlg, IDC_TOOLTIP, s);
  106.     
  107.     n = GetMyRegLong(NULL, "BalloonFlg", 0);
  108.     n = GetMyRegLong(m_section, "Style", n);
  109.     CheckRadioButton(hDlg, IDC_TOOLTIPSTYLE1, IDC_TOOLTIPSTYLE2,
  110.         IDC_TOOLTIPSTYLE1 + n);
  111.     
  112.     n = GetMyRegLong(NULL, "TipDispTime", 5);
  113.     n = GetMyRegLong(m_section, "DispTime", n);
  114.     UpDown_SetRange(hDlg, IDC_TOOLTIPTIMESPIN, 32, 0);
  115.     UpDown_SetPos(hDlg, IDC_TOOLTIPTIMESPIN, n);
  116.     
  117.     OnUseTip1(hDlg);
  118.     
  119.     m_bInit = TRUE;
  120. }
  121.  
  122. /*------------------------------------------------
  123.    apply - save settings
  124. --------------------------------------------------*/
  125. void OnApply(HWND hDlg)
  126. {
  127.     char s[BUFSIZE_TOOLTIP];
  128.     int n;
  129.     
  130.     if(!m_bChanged) return;
  131.     m_bChanged = FALSE;
  132.     
  133.     SetMyRegLong(m_section, "Tip1Use",
  134.         IsDlgButtonChecked(hDlg, IDC_USETOOLTIP1));
  135.     
  136.     GetDlgItemText(hDlg, IDC_TOOLTIP, s, BUFSIZE_TOOLTIP);
  137.     SetMyRegStr(m_section, "Tooltip", s);
  138.     
  139.     if(IsDlgButtonChecked(hDlg, IDC_TOOLTIPSTYLE2))
  140.         SetMyRegLong(m_section, "Style", 1);
  141.     else SetMyRegLong(m_section, "Style", 0);
  142.     
  143.     DelMyReg(NULL, "BalloonFlg");
  144.     
  145.     n = GetDlgItemInt(hDlg, IDC_TOOLTIPTIME, NULL, FALSE);
  146.     SetMyRegLong(m_section, "DispTime", n);
  147.     DelMyReg(NULL, "TipDispTime");
  148. }
  149.  
  150. /*------------------------------------------------
  151.    "Show tooltip"
  152. --------------------------------------------------*/
  153. void OnUseTip1(HWND hDlg)
  154. {
  155.     BOOL b = IsDlgButtonChecked(hDlg, IDC_USETOOLTIP1);
  156.     HWND hwnd = GetWindow(GetDlgItem(hDlg, IDC_USETOOLTIP1), GW_HWNDNEXT);
  157.     
  158.     while(hwnd)
  159.     {
  160.         EnableWindow(hwnd, b);
  161.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  162.     }
  163. }
  164.  
  165.